<?php

/**
 * Subcontract form base class.
 *
 * @method Subcontract getObject() Returns the current form's model object
 *
 * @package    seth
 * @subpackage form
 * @author     Fuz
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseSubcontractForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'       => new sfWidgetFormInputHidden(),
      'plant'    => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Plant'), 'add_empty' => false)),
      'supplier' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Supplier'), 'add_empty' => false)),
      'type'     => new sfWidgetFormInputText(),
      'fee'      => new sfWidgetFormInputText(),
      'start'    => new sfWidgetFormDate(),
      'end'      => new sfWidgetFormDate(),
      'note'     => new sfWidgetFormInputText(),
      'name'     => new sfWidgetFormInputText(),
      'status'   => new sfWidgetFormInputText(),
      'payments' => new sfWidgetFormInputText(),
    ));

    $this->setValidators(array(
      'id'       => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'plant'    => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Plant'))),
      'supplier' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Supplier'))),
      'type'     => new sfValidatorString(array('max_length' => 45)),
      'fee'      => new sfValidatorNumber(array('required' => false)),
      'start'    => new sfValidatorDate(array('required' => false)),
      'end'      => new sfValidatorDate(array('required' => false)),
      'note'     => new sfValidatorString(array('max_length' => 160, 'required' => false)),
      'name'     => new sfValidatorString(array('max_length' => 45)),
      'status'   => new sfValidatorString(array('max_length' => 20, 'required' => false)),
      'payments' => new sfValidatorString(array('max_length' => 45, 'required' => false)),
    ));

    $this->widgetSchema->setNameFormat('subcontract[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Subcontract';
  }

}
